'use strict';
const db = uniCloud.database()
const collection = db.collection('user')
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	if (event.type == 'get') {
		let res = collection.get()
		//返回数据给客户端
		return res
	} else if (event.type == 'del') {
		let res = await collection.where({
			_id: event.userId
		}).remove()
		// 成功删除的条数
		if (res.deleted == 1) {
			return {
				status: 0
			}
		} else {
			return {
				status: 1
			}
		}
	} else if (event.type == 'detail') {
		let res = await collection.where({
			_id: event.userId
		}).get()
		//返回数据给客户端
		return res
	} else if (event.type == 'update') {
		let res = await collection.where({
			_id: event.userId
		})

	}

};